<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>医生个人排班</title>
    <script type="text/javascript">
        $(function (){
            var id= $("#root").val();
            $.ajax({
                url:"/lsy/getWorkBydName",
                type:"GET",
                data: {
                    "workforcesDoctor": id
                },
                dataType:"json",
                success:function (workForcesList) {
                    if (workForcesList.flag=='1'){
                        if (workForcesList.workForcesList!=null){
                            show(workForcesList.workForcesList);
                        }else {
                            alert("查询结果为空！")
                        }
                    }else {
                        alert("查询结果为空！")
                    }
                },
                error:function (workForcesList) {
                    alert("查询排班失败!")
                }
            })
        })
        Date.prototype.format=function (format){
            var o={
                "M+" : this.getMonth() + 1, // month
                "d+" : this.getDate(), // day
                "H+" : this.getHours(), // hour
                "m+" : this.getMinutes(), // minute
                "s+" : this.getSeconds(), // second
                "q+" : Math.floor((this.getMonth() + 3) / 3), // quarter
                "S" : this.getMilliseconds()
            }
            if (/(y+)/.test(format)){
                format=format.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length));
            }
            for (var k in  o){
                if (new RegExp("("+k+")").test(format)){
                    format=format.replace(RegExp.$1,RegExp.$1.length==1 ? 0[k]: ("00" +o[k]).substr((""+o[k]).length));
                }
            }
            return format;
        }
        function show(workForcesList){
            var workForces="";
            for (var i = 0; i < workForcesList.length; i++) {
                workForces +='<tr>'
                    +'<td>'+workForcesList[i].departmentName+'</td>'
                    +'<td>' +workForcesList[i].dname +'</td>'
                    +'<td>'+new Date(workForcesList[i].workforcesTime).format("yyyy-MM-dd")+'</td>'
                    +'<td>'+new Date(workForcesList[i].onTime).format("yyyy-MM-dd HH:mm:ss")+'</td>'
                    +'<td>'+new Date(workForcesList[i].downTime).format("yyyy-MM-dd HH:mm:ss")+'</td>'
                    +'<td>'+workForcesList[i].maxRegistration+'</td>'
                    +'<td>'+workForcesList[i].registration+'</td>'
                    +'</tr>';
            }
            $("#root").append(workForces);
        }
    </script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        table {
            width: 800px;
            border-collapse: collapse;
        }

        table tr {
            display: -webkit-flex;
            display: flex;
        }

        table tr th,
        table tr td {
            flex: 1;
            padding: 10px 0;
            text-align: center;
            border: 1px solid #e1e8f6;
        }

        table tr th {
            background-color: #dddddd;
        }
    </style>
</head>
<body>
<div>
    <table id="all-requst">
        <thead>
        <tr>
            <th>科室名称</th>
            <th>医生姓名</th>
            <th>排班日期</th>
            <th>上班时间</th>
            <th>下班时间</th>
            <th>最大挂号数</th>
            <th>剩余挂号数</th>
        </tr>
        </thead>
        <tbody id="root" th:value="${workforcesDoctor}">

        </tbody>
    </table>
</div>


</body>
</html>